package com.fqr;

import java.io.File;
import java.util.ArrayList;

public class EmailDestination extends Destination {
	private String subject;
	private String fromAddress;
	private String message;
	private ArrayList<String> toAddress = new ArrayList<String>();
	private String filename;

	private String src;

	public EmailDestination() {
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getFromAddress() {
		return fromAddress;
	}

	public void setFromAddress(String fromAddress) {
		this.fromAddress = fromAddress;
	}

	public ArrayList<String> getToAddress() {
		return toAddress;
	}

	public void setToAddress(ArrayList<String> toAddress) {
		this.toAddress = toAddress;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public String getFilename() {
		return filename;
	}

	public String getDestinationFilename() {
		return formatFilename(src, filename);
	}

	public void send(String src) {
		EmailInfo emailObject = new EmailInfo();
		emailObject.setEmailfromAdd(fromAddress);
		emailObject.setEmailrecAdd(toAddress);
		emailObject.setEmailfileAttachment(src != null ? new File(src) : null);
		emailObject.setEmailFileAttachmentName(getDestinationFilename());
		emailObject.setEmailSubject(subject);
		emailObject.setEmailMessage(message);

		EmailUtil emailUtil = new EmailUtil();
		emailUtil.sendEmail(emailObject);
	}

}
